package com.example.springdemo.others.thread;


/**
 * 线程池与主线程的执行顺序问题
 * @author zhangding
 * @date 2022年11月29日10:03:01
 */
public class ThreadPractice {



    public static void main(String[] args) throws InterruptedException {
        // 若是嵌套线程，将无法控制子线程的执行
        Thread thread = new Thread(()->{
            // 若无子线程，使用join可以控制顺序
            Thread thread1 = new Thread(()->{
                try {
                    Thread.sleep(3000);
                    System.out.println("7777");
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            });
            thread1.start();
        });
        thread.start();
        thread.join();
        System.out.println("运行到主线程了");

    }

}
